package com.me.libgdx_test;

import java.io.File;

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;

public class AbstractClassAssetHolder {
	
	private AssetManager manager = new AssetManager();
	private ClassLogDisplay logger = new ClassLogDisplay("ClassAbstractAssetHolder");
	private String path = new File("").getAbsolutePath().replace("\\", "/") + "/../pocket_quest-android/assets/data/";
	
	public boolean check_assets(){
		return manager.getLoadedAssets()>0;
	}
	
	public AssetManager get_assets(){
		return manager;
	}
	
	public void load_assets(){
		logger.print("Load Assets");
		File folder = new File(path);
		File[] listOfFiles = folder.listFiles();
		for(File file:listOfFiles){
			try{
				logger.print(file.getPath());
				//Need to add the music and effects here too
				manager.load(file.getPath(), Texture.class);
			}catch(Exception e){
				logger.print(String.valueOf(e));
			}
		}
		//This needs to be async eventually
		while(!manager.update()){}
	}

}
